/*
 * @Author: your name
 * @Date: 2021-12-29 10:12:07
 * @LastEditTime: 2022-04-08 10:17:25
 * @LastEditors: Aaron
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \ias_ui\src\api\coi\onlineTaskAPI\spu.js
 */
import request from '../../../utils/request.js'
import { exportFile } from '../../exportFile.js'
const prefix = process.env.VUE_APP_BASE_API11
const frpfix7 = process.env.VUE_APP_BASE_API7

const list_url = {
  spuListStatus: `${prefix}/spu/processStatus/getAllMainStatusTypes`,
  exportSpu: ``,
  spuManagementList: `${prefix}/spu/spuInfo/getSpuInfoPageList`,
  processData: `${prefix}/spu/processStatus/getProcessLogBySpuId`,
  addSpuList: `${prefix}/skuInfo/aloha/getSkuBaseInfoList`,
  spuSubmit: `${prefix}/spu/spuInfo/submit`,
  withdraw: `${prefix}/spu/spuInfo/withdraw`,
  spuSeriesList: ``,
  whiteVendorList: `${frpfix7}/vendor-info/query/vendorInfo`,
  batchEditWhiteVendor: `${frpfix7}/vendor-info/config/whiteList`,
  submitSpuSend: `${prefix}/spu/spuInfo/initSpu`,
  getVerificationInfo: `${prefix}/spu/spuInfo/getSpuDetailById`,
  addSpuSkuMapping: `${prefix}/spu/sku/addSpuSkuMapping`,
  deleteSpuSkuMapping: `${prefix}/spu/sku/deleteSpuSkuMapping`,
  setSpuSaleAttrSort: `${prefix}/spu/spuInfo/setSpuSaleAttrSort`,
  setSpuSeriesInfo: `${prefix}/spu/spuInfo/setSpuSeriesInfo`,
  uploadSpuResource: `${prefix}/spu/resource/uploadSpuResource`,
  uploadSpuContentResource: `${prefix}/spu/resource/uploadSpuContentResource`,
  uploadSaleAttrValueResource: `${prefix}/spu/resource/uploadSaleAttrValueResource`,
  deleteSpuResource: `${prefix}/spu/resource/deleteSpuResource`,
  deleteSpuContentResource: `${prefix}/spu/resource/deleteSpuContentResource`,
  deleteSaleAttrValueResource: `${prefix}/spu/resource/deleteSaleAttrValueResource`,
  getSpuInfoPageList: `${prefix}/spu/spuInfo/content/getSpuInfoPageList`,
  pushSpu: `${prefix}/spu/spuInfo/pushSpu`,
  abandonRequest: `${prefix}/spu/spuInfo/cancellation`,
  exportTemplate: `${prefix}/spu/spuInfo/exportSpuBatchTemplate`,
  uploadTemplate: `${prefix}/spu/spuInfo/importSpuBatchExcel`
}

const content_url = {
  saveSpuChannelInfo: `${prefix}/spu/spuInfo/saveSpuChannelInfo`,
  setSpuChannelInfo: `${prefix}/spu/spuInfo/setSpuChannelInfo`,
  saveSpuContent: `${prefix}/spu/spuInfo/saveSpuContent`,
  setSpuContent: `${prefix}/spu/spuInfo/setSpuContent`,
  getSkuAttrInfo: `${prefix}/skuInfo/aloha/getSkuAttrInfo`,
  updateSkuAttr: `${prefix}/skuInfo/aloha/spu/updateSkuAttr`
}

export const spuListStatus = () => {
  return request({
    method: 'get',
    url: list_url.spuListStatus
  })
}

// 列表导出
export const exportSpu = (data, name) => {
  return exportFile(list_url.exportSpu, data, name)
}

// 列表导出
export const exportSpuText = (data, name) => {
  return exportFile(list_url.exportSpu, data, name)
}

// spu管理列表
export const spuManagementList = (data) => {
  return request({
    method: 'post',
    url: list_url.spuManagementList,
    data
  })
}

// 查看操作日志
export const processData = (params) => {
  return request({
    method: 'get',
    url: list_url.processData,
    params
  })
}

// 新增spu列表的查询
export const addSpuListData = (data) => {
  return request({
    method: 'post',
    url: list_url.addSpuList,
    data
  })
}

// spu提交
export const spuSubmit = (data) => {
  return request({
    method: 'post',
    url: list_url.spuSubmit,
    data
  })
}

// spu撤回
export const withdraw = (data) => {
  return request({
    method: 'post',
    url: list_url.withdraw,
    data
  })
}

// spu系列列表
export const spuSeriesList = (data) => {
  return request({
    method: 'post',
    url: list_url.spuSeriesList,
    data
  })
}
// spu发起
export const submitSpuSend = (data) => {
  return request({
    method: 'post',
    url: list_url.submitSpuSend,
    data
  })
}

// spu校验
export const getVerificationInfo = (params) => {
  return request({
    method: 'get',
    url: list_url.getVerificationInfo,
    params
  })
}
// 白名单供应商
export const whiteVendorList = (params) => {
  return request({
    method: 'post',
    url: list_url.whiteVendorList,
    data: params
  })
}
// 批量修改白名单
export const batchEditWhiteVendor = (params) => {
  return request({
    method: 'post',
    url: list_url.batchEditWhiteVendor,
    data: params
  })
}

// add UPC到spu映射
export const addSpuSkuMapping = (data) => {
  return request({
    method: 'post',
    url: list_url.addSpuSkuMapping,
    data
  })
}

// add UPC到spu映射
export const deleteSpuSkuMapping = (params) => {
  return request({
    method: 'get',
    url: list_url.deleteSpuSkuMapping,
    params
  })
}

// 保存销售属性排序
export const setSpuSaleAttrSort = (data) => {
  return request({
    method: 'post',
    url: list_url.setSpuSaleAttrSort,
    data
  })
}

// 保存Spu系类
export const setSpuSeriesInfo = (data) => {
  return request({
    method: 'post',
    url: list_url.setSpuSeriesInfo,
    data
  })
}

// spu图片上传
export const uploadSpuResource = (data) => {
  return request({
    method: 'PUT',
    url: list_url.uploadSpuResource,
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// spu销售属性图片上传
export const uploadSaleAttrValueResource = (data) => {
  return request({
    method: 'PUT',
    url: list_url.uploadSaleAttrValueResource,
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// spu文描图片上传
export const uploadSpuContentResource = (data) => {
  return request({
    method: 'PUT',
    url: list_url.uploadSpuContentResource,
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// spu图片删除
export const deleteSpuResource = (data) => {
  return request({
    method: 'post',
    url: list_url.deleteSpuResource,
    data
  })
}

// spu销售属性图片删除
export const deleteSaleAttrValueResource = (data) => {
  return request({
    method: 'post',
    url: list_url.deleteSaleAttrValueResource,
    data
  })
}

// spu文描删除
export const deleteSpuContentResource = (data) => {
  return request({
    method: 'post',
    url: list_url.deleteSpuContentResource,
    data
  })
}

// 保存渠道信息
export const saveSpuChannelInfo = (data) => {
  return request({
    method: 'post',
    url: content_url.saveSpuChannelInfo,
    data
  })
}

// 保存渠道信息
export const setSpuChannelInfo = (data) => {
  return request({
    method: 'post',
    url: content_url.setSpuChannelInfo,
    data
  })
}

/**
 * spu文描团队
 */

// 文描spu管理列表
export const getSpuInfoPageList = (data) => {
  return request({
    method: 'post',
    url: list_url.getSpuInfoPageList,
    data
  })
}

export const pushSpu = (data) => {
  return request({
    method: 'POST',
    url: list_url.pushSpu,
    data
  })
}

// 保存渠道信息
export const saveSpuContent = (data) => {
  return request({
    method: 'post',
    url: content_url.saveSpuContent,
    data
  })
}

// 保存渠道信息
export const setSpuContent = (data) => {
  return request({
    method: 'post',
    url: content_url.setSpuContent,
    data
  })
}
// 作废
export const abandonRequest = (data) => {
  return request({
    method: 'post',
    url: list_url.abandonRequest,
    data
  })
}

// 下载spu模板
export const exportTemplate = () => {
  return exportFile(list_url.exportTemplate, {}, '批量创建SPU模板')
}

// spu模板上传
export const uploadTemplate = (data, fileName) => {
  return exportFile(list_url.uploadTemplate, data, fileName, { method: 'put', headers: { 'Content-Type': 'multipart/form-data' } })
}

// 获取sku下沉属性
export const getSkuAttrInfo = (data) => {
  return request({
    method: 'post',
    url: content_url.getSkuAttrInfo,
    data
  })
}

// 保存sku下沉属性
export const updateSkuAttr = (data) => {
  return request({
    method: 'post',
    url: content_url.updateSkuAttr,
    data
  })
}
